<template>
  <div>
    <router-view></router-view>
  </div>
</template>

<script>
import dingMixin from  '@/mixins/ding'
import * as dd from 'dingtalk-jsapi'
export default {
  mixins: [dingMixin],
  watch: {
    $route (to, from) {
      if(to.meta.title) this.mobileSetTitle(to.meta.title);
    }
  },
  mounted() {
    let clientWidth = document.documentElement['clientWidth'] < 800;
    this.getDingConfig().then(config =>{
      this.dingConfig = config;
      this.dingLogin(config.corpId, () => {
        let type = this.$route.query.type;
        let id = this.$route.query.id;
        if (this.isPC() && !clientWidth) {
          if(type === 'sh') {
            this.$router.replace({ name: 'project-check'})
          }else if(type === 'pf') {
            this.$router.replace({ name: 'project-assess'})
          }else if(type === 'jg') {
            this.$router.replace({ name: 'project-list' , params: {id: id}})
          }else {
            this.$router.replace({ name: 'project-list'})
          }
        }else {
          if(type === 'sh') {
            this.$router.replace({ name: 'mproject-check'})
          }else if(type === 'pf') {
            this.$router.replace({ name: 'mproject-assess'})
          }else if(type === 'jg') {
            this.$router.replace({ name: 'mproject-list' , params: {id: id}})
          }else {
            this.$router.replace({ name: 'mproject-list'})
          }
        }
      });
      this.run_dd_config();
  })
  }
}
</script>
<style lang="scss" scoped>
// div {
//   background-color: #F5F5F5;
//   height: 100vh;
// }
</style>